<template>
  <div>

    <el-table
        :data="tableData"
        border
        style="width: 100% ">
      <el-table-column
          fixed
          prop="id"
          label="ID"
          width="200">
      </el-table-column>
      <el-table-column
          prop="name"
          label="Name"
          width="200">
      </el-table-column>

      <el-table-column
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button @click="edit(scope.row)" type="text" size="small">查看或修改</el-button>

        </template>
      </el-table-column>
    </el-table>

    <!--实现分页查询-->
    <el-pagination
        background
        layout="prev, pager, next"
        page-size="8"
        :total=counts
        @current-change="page">
    </el-pagination>

  </div>

</template>

<script>
export default {
  methods: {
    page(currentPage) {
      //alert(currentPage)
      const _this = this
      //此处需要查询item的全部信息
      axios({
        method: "GET",
        url: 'http://115.29.176.82:8081/manager/api/category',
        params: {
          size: 8,
          page: currentPage
        }
      }).then(function (resp) {
        _this.tableData = (resp.data.data.list)
      })
    },

    edit(row) {
      this.$router.push({
        path: '/categoryupdate',
        query: {
          id: row.id,
          name:row.name,

        }
      })

    },

    //此处需要根据productid删除提供的数据接口+row.productid
    deleteproduct(row) {
      axios.delete('           ').then(function (resp) {
        alert('删除成功')
        window.location.reload()
      })

    },

  },
  created() {
    const _this = this
    //此处需要查询item的全部信息
    axios({
      method:"GET",
      url:'http://115.29.176.82:8081/manager/api/category',
      params:{
        size:8,
        page:1
      }
    }).then(function (resp){
     _this.counts=resp.data.data.counts
      _this.tableData = (resp.data.data.list)
    })

  },
  data() {
    return {
      category:'',
      tableData: [],
      counts:null

    }
  },

}
</script>